using UnityEngine;
using System.Collections;

public class CharacterAction: MonoBehaviour
{ 
	public Character character { get { return frame.state.character; } }
	public CharacterAnimatedState state { get { return frame.state; } }
	[System.NonSerialized] public CharacterKeyFrame frame;

	protected bool onFrameUpdate = true;

	public virtual void Init(CharacterKeyFrame frame)
	{
		this.frame = frame;
	}

	/** override to implement, and register event hanlders here*/
	public virtual void OnActionEnter(Character character)
	{
		if(onFrameUpdate)
			character.onFrameUpdate.OnEvent += OnFrameUpdate;
	}

	/** override to implement, and unregister event hanlders here*/
	public virtual void OnActionExit(Character character)
	{
		if(onFrameUpdate)
			character.onFrameUpdate.OnEvent -= OnFrameUpdate;
	}


	/** override to implement*/
	public virtual void OnFrameUpdate(Character.FrameUpdate arg)
	{
		// do nothing
	}
}

